import {
RIG_OPERATOR_CHART_VERSION
} from "../../../src/constants/versions"
import CodeBlock from '@theme/CodeBlock';

# Rig Operator

## Setup guide

Installing the Rig Operator is a easy as any other Kubernetes operator. We've made a
Helm chart available the makes it easy to get all the resources up and running.

## Installation

To install the operator run:

<CodeBlock language="bash">
{`helm upgrade --install rig-operator rig-operator \\
  --repo https://charts.rig.dev \\
  --version ${RIG_OPERATOR_CHART_VERSION} \\
  --namespace rig-system \\
  --create-namespace
`}
</CodeBlock>

## Configuration

The Rig Operator has a lot of configuration options for how to treat Capsules in
the current cluster. The configuration is easily provided as part of a values file for
the Helm Chart.

The entire config is described [here](https://github.com/rigdev/rig/blob/main/deploy/charts/rig-operator/values.yaml),
but is simply a YAML file with configuration parameters.

### Example - External Platform token

To configure the operator to generate access for a Rig Platform deployed *outside*
cluster, a ServiceAccount with a Secret (token) can easily be configured:

```yaml title="Helm values - Operator"
rbac:
  platform:
    create_token: true
```

After creation, the Secret containing the token and CA authority can be read:

```bash
kubectl get -n rig-system secret/rig-platform-token -o='jsonpath={.data.token}' | base64 -d
kubectl get -n rig-system secret/rig-platform-token -o='jsonpath={.data.ca\.crt}' | base64 -d
```

### Example - Configure Service-Type

To configure the operator to produce Service resources with ServiceType `NodePort` instead of `ClusterIP`,
the following operator will do that for us:

```yaml title="Helm values - Operator"
config:
  service:
    type: NodePort
```

### Applying the configuration

To apply a config to a cluster, save the file as `operator.yaml` run the following command:

<CodeBlock language="bash">
{`helm upgrade --install rig-operator rig-operator \\
  --repo https://charts.rig.dev \\
  --version ${RIG_OPERATOR_CHART_VERSION} \\
  --namespace rig-system \\
  --create-namespace \\
  -f operator.yaml
`}
</CodeBlock>

This can be done several times, after each change.
